﻿
using System;
using System.Data;
using System.Xml;
using System.Data.OleDb;
using System.Collections;

namespace CarolLib.Helper
{
    public sealed class OleDbHelper
    {
        public static DataSet ExecuteDataset(string connectionString, CommandType commandType, string commandText)
        {
            using (OleDbConnection conn = new OleDbConnection(connectionString))
            {
                OleDbDataAdapter OdbcAda = new OleDbDataAdapter();
                OdbcAda.SelectCommand = new OleDbCommand();
                OdbcAda.SelectCommand.Connection = conn;
                OdbcAda.SelectCommand.CommandType = CommandType.Text;
                OdbcAda.SelectCommand.CommandText = commandText;

                DataSet ds = new DataSet();
                OdbcAda.Fill(ds);
                return ds;
            }
        }

        public static OleDbDataReader ExecuteReader(string connectionString, CommandType commandType, string commandText)
        {
            OleDbConnection conn = new OleDbConnection(connectionString);
            conn.Open();
            OleDbCommand cmd = new OleDbCommand(commandText,conn);
            cmd.CommandType = CommandType.Text;
            return cmd.ExecuteReader();
        }
    }
}